package org.yanh.common.client.fallback;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.yanh.common.client.ItemClient;
import org.yanh.common.domain.dto.ItemDTO;
import org.yanh.common.domain.dto.OrderDetailDTO;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@Slf4j
public class ItemClientFallback implements FallbackFactory<ItemClient> {
    @Override
    public ItemClient create(Throwable cause) {
        return new ItemClient() {
            @Override
            public List<ItemDTO> queryItemByIds(Collection<Long> ids) {
                List<ItemDTO> fallback=new ArrayList<>();

                return fallback ;
            }

            @Override
            public void deductStock(List<OrderDetailDTO> items) {
            }

            @Override
            public String queryItemTest() {
                return "fallback";
            }
        };
    }
}